#ifndef SKETCHCONTROLLER_H
#define SKETCHCONTROLLER_H

#include <QObject>
#include <QVector>
#include <QPoint>
#include <QVector2D>
#include <QVector3D>
#include "Tetrahedron.h"
#include "curven.hpp"
#include "bernsteinpolyline.h"

class Tetrahedron;

class SketchController : public QObject
{
    Q_OBJECT

    QVector<QVector2D> curve2D;
    QVector<QVector2D> temp;
    QVector<QVector3D> curve3D;
    QVector<Curve3D> curves;
    QVector<QVector3D> points;
    QVector<QVector3D> normmals;

    Tetrahedron *tetra;

    bool showLines;
    bool showPoints;

public:
    explicit SketchController(Tetrahedron *t, QObject *parent = 0);

    
signals:
    void samplerPointsDone();
    
public slots:
    void mouseRigthMove(QPoint begin, QPoint curr);
    void mouseRigthFinish(QPoint ini, QPoint curr);
    void draw();
    void makeSurface();
    const QVector<QVector3D>& getPoints();
    QVector<QPair<QVector3D, QVector3D> > getPointsAndNormals();
    void clear();

    void setShowLines(bool v);
    void setShowPoints(bool v);


private:
    void processaCurva();
    TRIANGLE toDeviceSpace(const TRIANGLE& t);
    QVector3D toObjectSpace(const QVector3D& v);
    void connectPoints();
    void samplerPoints();


};

#endif // SKETCHCONTROLLER_H
